{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">角色{:lang('list')}</div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"></table>
            <script type="text/html" id="authTool">
                <a class='layui-btn layui-btn-warm layui-btn-xs' data-open='{:url('access')}?id={{d.id}}' title="访问授权"><i class="layui-icon layui-icon-set-sm"></i></a>
                <a data-open='{:url("edit")}?id={{ d.id }}' class="layui-btn layui-btn-xs" title="编辑"><i class="layui-icon layui-icon-edit"></i></a>
                {{# if(d.id==1){ }}
                <a class="layui-btn layui-btn-danger layui-btn-xs layui-btn-disabled"><i class="layui-icon layui-icon-delete"></i></a>
                {{# }else{  }}
                <a href='{:url("del")}?ids={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del"><i class="layui-icon layui-icon-delete"></i></a>
                {{# } }}
            </script>
            <script type="text/html" id="status">
                {{# if(d.id==1){ }}
                <input type="checkbox" disabled name="status" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" data-href="{:url('state')}" lay-filter="status" checked>
                {{# }else{  }}
                <input type="checkbox" name="status"  value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" data-href="{:url('state')}" lay-filter="status" {{ d.status == 1 ? 'checked' : '' }}>
                {{# } }}
            </script>

        </div>
    </div>
</div>
{/block}
{block name="script"}
<script>
    layui.use('yznTable', function() {
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            add_url: "{:url('add')}",
            delete_url: "{:url('del')}",
            modify_url: '{:url("multi")}',
        };

        table.render({
            init: init,
            id: 'currentTable',
            elem: '#currentTable',
            toolbar: ['refresh',
                [{
                    text: '添加',
                    url: init.add_url,
                    method: 'open',
                    class: 'layui-btn layui-btn-normal layui-btn-sm',
                    icon: 'layui-icon layui-icon-addition',
                    extend: 'data-width="900px" data-height="600px"',
                }], 'delete'
            ],
            url: '{:url("index")}',
            cols: [
                [
                    {checkbox: true, fixed: true, width: 80,},
                    {field: 'id', title: 'ID', width: 80, fixed: true, sort: true},
                    {field: 'sort', width: 80, title: '排序',fixed: true, edit: 'text',align:"center"},
                    {field: 'title', title: '角色名称'},
                    {field: 'status', title: '状态', width: 180, templet:'#status', align:"center"},
                    {field: 'create_time', title: '添加时间', width: 180, align:"center", search:false},
                    {field: 'update_time', title: '修改时间', width: 180, align:"center", search:false},
                    {fixed: 'right', title:'操作',width:200, toolbar: '#authTool', align:"center"},
                ]
            ],
            page: {}
        });
    });
</script>
{/block}